package main

import (
	"fmt"
	"math/rand"
	"runtime"
	"sync"
	"time"
)
//goroutine

func hello(i int) {
	fmt.Println("Hello", i)
}

func f(){
	for i := 0; i < 5; i++{
		rand.Seed(time.Now().UnixNano())
		r1 := rand.Int()
		r2 := rand.Intn(10)
		fmt.Println(r1, r2)
	}
}

func f1(i int) {
	defer wg.Done()
	time.Sleep(time.Millisecond * time.Duration(rand.Intn(300)))
	fmt.Println(i)
}

func a(){
	defer wg.Done()
	for i:= 0; i < 10; i++{
		fmt.Println("a", i)
	}
}

func b(){
	defer wg.Done()
	for i:= 0; i < 10; i++{
		fmt.Println("b", i)
	}
}

// 程序启动后也会创建一个main的goroutine
var wg sync.WaitGroup
func main() {
	c := runtime.NumCPU()
	fmt.Println(c)
}
